package com.riip.demos.elasticjob.controller;

import com.riip.demos.elasticjob.model.Job;
import com.riip.demos.elasticjob.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: demos
 * @description:
 * @author: 刘振华
 * @create: 2020-03-17 13:53
 **/
@RestController
@RequestMapping("/job")
public class JobController {
	@Autowired
	private JobService jobService;

	/**
	 * job需要不同的jobName
	 *
	 * @return
	 */
	@GetMapping("")
	public Object add() {
		Job job = new Job();
		job.setJobName("add");
		jobService.addJob(job);
		return "OK";
	}

	@GetMapping("/add1")
	public Object add1() {
		Job job = new Job();
		job.setJobName("add1");
		job.setCron("0/8 * * * * ?");
		jobService.addJob(job);
		return "OK";
	}

}
